//
//  AgeInPutView.m
//  夺宝吧
//
//  Created by xiaocai on 15/7/21.
//  Copyright (c) 2015年 FangYuan. All rights reserved.
//

#import "AgeInPutView.h"

@interface AgeInPutView()<UIPickerViewDataSource,UIPickerViewDelegate>
{
    __weak IBOutlet UIButton *ensureBtn;
    __weak IBOutlet UIButton *cancelBtn;
    
    __weak IBOutlet UIPickerView *AgePicker;
    NSString *_currentAge;
}
@end
@implementation AgeInPutView
//设置默认值
- (void)morenzhi:(NSString *)age
{
    _currentAge = age;
    [AgePicker selectRow:[age integerValue] inComponent:0 animated:NO];
}
- (void)awakeFromNib
{
    ensureBtn.layer.cornerRadius = 2;
    cancelBtn.layer.cornerRadius = 2;
    ensureBtn.layer.borderWidth = 1;
    cancelBtn.layer.borderWidth = 1;
    ensureBtn.layer.masksToBounds = YES;
    cancelBtn.layer.masksToBounds = YES;
    ensureBtn.layer.borderColor = [UIColor whiteColor].CGColor;
    cancelBtn.layer.borderColor = [UIColor lightGrayColor].CGColor;
    ensureBtn.backgroundColor = QBB_RED_COLOR;
    self.layer.borderWidth = 1;
    self.layer.borderColor = [UIColor blackColor].CGColor;
    self.layer.cornerRadius = 5;
    self.layer.masksToBounds = YES;
    
    AgePicker.dataSource = self;
    AgePicker.delegate =  self;
    [AgePicker reloadAllComponents];
    
    
}

- (IBAction)ensurebtnOnClick:(id)sender {
    [self.father changeAge:_currentAge];
    [self removeFromSuperview];
}

- (IBAction)cancelBtnOnClick:(id)sender {
    [self.father removeZheZhao];
    [self removeFromSuperview];
}
#pragma mark pickerview function

/* return cor of pickerview*/
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}
/*return row number*/
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    return 110;
}

/*return component row str*/
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    return [NSString stringWithFormat:@"%ld",(unsigned long)row];
}

/*choose com is component,row's function*/
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    _currentAge = [NSString stringWithFormat:@"%ld",(unsigned long)row];
    
}


@end
